#include <cstdio>
#include <cstring>

#define MAXN 50+5
#define MAX(a,b) (a>b?a:b)

int M, N;
int MAP[MAXN][MAXN];
int DP[MAXN][MAXN][MAXN][MAXN];

int main() {
	scanf("%d%d", &M, &N);
	for (int i=1; i<=M; i++) {
		for (int j=1; j<=N; j++) {
			scanf("%d", &MAP[i][j]);
		}
	}
	for (int i=1; i<=M; i++) {
		for (int j=1; j<=N; j++) {
			for (int k=1; k<=M; k++) {
				for (int l=1; l<=N; l++) {
					DP[i][j][k][l] = MAX(MAX(DP[i-1][j][k-1][l], DP[i][j-1][k-1][l]), 
						MAX(DP[i-1][j][k][l-1], DP[i][j-1][k][l-1])) + 
						MAP[i][j] + MAP[k][l];
					if (i==k && j==l) DP[i][j][k][l] -= MAP[i][j];
				}
			}
		}
	}
	printf("%d\n", DP[M][N][M][N]);
	return 0;
}
